import 'dart:convert';

/// id : "78e6fae65e304c7a9d239b20632fbae4"
/// senderId : "9OrHH2"
/// roomId : "f8258e9c30ea43b59f80659f388600b9"
/// content : "。"
/// sentAt : "2023-06-03 23:03:36"
/// msgStatus : false
/// sentType : "2"
/// success : false
/// isDeleted : false
/// avatar : "https://i.ibb.co/k4qs5kg/3b6a614e0ad9.png"
/// nickName : "神秘用户"

ChatBean chatBeanFromJson(String str) => ChatBean.fromJson(json.decode(str));

String chatBeanToJson(ChatBean data) => json.encode(data.toJson());

class ChatBean {
  ChatBean({
    String? id,
    String? senderId,
    String? roomId,
    String? content,
    String? sentAt,
    bool? msgStatus,
    String? sentType,
    bool? success,
    bool? isDeleted,
    String? avatar,
    String? nickName,
  }) {
    _id = id;
    _senderId = senderId;
    _roomId = roomId;
    _content = content;
    _sentAt = sentAt;
    _msgStatus = msgStatus;
    _sentType = sentType;
    _success = success;
    _isDeleted = isDeleted;
    _avatar = avatar;
    _nickName = nickName;
  }

  ChatBean.fromJson(dynamic json) {
    _id = json['id'];
    _senderId = json['senderId'];
    _roomId = json['roomId'];
    _content = json['content'];
    _sentAt = json['sentAt'];
    _msgStatus = json['msgStatus'];
    _sentType = json['sentType'];
    _success = json['success'];
    _isDeleted = json['isDeleted'];
    _avatar = json['avatar'];
    _nickName = json['nickName'];
  }

  String? _id;
  String? _senderId;
  String? _roomId;
  String? _content;
  String? _sentAt;
  bool? _msgStatus;
  String? _sentType;
  bool? _success;
  bool? _isDeleted;
  String? _avatar;
  String? _nickName;

  ChatBean copyWith({
    String? id,
    String? senderId,
    String? roomId,
    String? content,
    String? sentAt,
    bool? msgStatus,
    String? sentType,
    bool? success,
    bool? isDeleted,
    String? avatar,
    String? nickName,
  }) =>
      ChatBean(
        id: id ?? _id,
        senderId: senderId ?? _senderId,
        roomId: roomId ?? _roomId,
        content: content ?? _content,
        sentAt: sentAt ?? _sentAt,
        msgStatus: msgStatus ?? _msgStatus,
        sentType: sentType ?? _sentType,
        success: success ?? _success,
        isDeleted: isDeleted ?? _isDeleted,
        avatar: avatar ?? _avatar,
        nickName: nickName ?? _nickName,
      );

  String? get id => _id;

  String? get senderId => _senderId;

  String? get roomId => _roomId;

  String? get content => _content;

  String? get sentAt => _sentAt;

  bool? get msgStatus => _msgStatus;

  String? get sentType => _sentType;

  bool? get success => _success;

  bool? get isDeleted => _isDeleted;

  String? get avatar => _avatar;

  String? get nickName => _nickName;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    map['senderId'] = _senderId;
    map['roomId'] = _roomId;
    map['content'] = _content;
    map['sentAt'] = _sentAt;
    map['msgStatus'] = _msgStatus;
    map['sentType'] = _sentType;
    map['success'] = _success;
    map['isDeleted'] = _isDeleted;
    map['avatar'] = _avatar;
    map['nickName'] = _nickName;
    return map;
  }
}
